X-Git-Url: http://git.cyclocoop.org/%22.%24match%5B1%5D.%22?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBlock.php;h=6156766a70d0b1e81bf0e292568eb51f73a8cca6;hb=4d6828ef7835b7c5c5e903637fcba4bf5c487e1b;hp=0cf790bddad8d7a5d04019388d4620e2e68f9473;hpb=f2b01310d90060ba2ccba3e6d36b67e942bff978;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 0cf790bdda..6156766a70 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -21,9 +21,9 @@ * @ingroup SpecialPage */ -use MediaWiki\Block\BlockRestriction; use MediaWiki\Block\Restriction\PageRestriction; use MediaWiki\Block\Restriction\NamespaceRestriction; +use MediaWiki\MediaWikiServices; /** * A special page that allows users with 'block' right to block users from @@ -141,7 +141,9 @@ class SpecialBlock extends FormSpecialPage { * @return array */ protected function getFormFields() { - global $wgBlockAllowsUTEdit; + $conf = $this->getConfig(); + $enablePartialBlocks = $conf->get( 'EnablePartialBlocks' ); + $blockAllowsUTEdit = $conf->get( 'BlockAllowsUTEdit' ); $this->getOutput()->enableOOUI(); @@ -149,9 +151,6 @@ class SpecialBlock extends FormSpecialPage { $suggestedDurations = self::getSuggestedDurations(); - $conf = $this->getConfig(); - $enablePartialBlocks = $conf->get( 'EnablePartialBlocks' ); - $a = []; $a['Target'] = [ @@ -232,7 +231,7 @@ class SpecialBlock extends FormSpecialPage { ]; } - if ( $wgBlockAllowsUTEdit ) { + if ( $blockAllowsUTEdit ) { $a['DisableUTEdit'] = [ 'type' => 'check', 'label-message' => 'ipb-disableusertalk', @@ -308,18 +307,6 @@ class SpecialBlock extends FormSpecialPage { 'cssclass' => 'mw-block-confirm', ]; - // Block Id if a block already exists matching the target - $a['BlockId'] = [ - 'type' => 'hidden', - 'default' => '', - ]; - - // Has the form been submitted - $a['WasPosted'] = [ - 'type' => 'hidden', - 'default' => '', - ]; - $this->maybeAlterFormDefaults( $a ); // Allow extensions to add more fields @@ -397,14 +384,14 @@ class SpecialBlock extends FormSpecialPage { $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->getExpiry() ); } - $fields['BlockId']['default'] = $block->getId(); - $this->alreadyBlocked = true; $this->preErrors[] = [ 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) ]; } - if ( $this->getRequest()->wasPosted() ) { - $fields['WasPosted']['default'] = true; + if ( $this->alreadyBlocked || $this->getRequest()->wasPosted() + || $this->getRequest()->getCheck( 'wpCreateAccount' ) + ) { + $this->getOutput()->addJsConfigVars( 'wgCreateAccountDirty', true ); } # We always need confirmation to do HideUser @@ -632,6 +619,7 @@ class SpecialBlock extends FormSpecialPage { * the HTMLForm * @param WebRequest|null $request Optionally try and get data from a request too * @return array [ User|string|null, Block::TYPE_ constant|null ] + * @phan-return array{0:User|string|null,1:int|null} */ public static function getTargetAndType( $par, WebRequest $request = null ) { $i = 0; @@ -961,8 +949,9 @@ class SpecialBlock extends FormSpecialPage { $currentBlock->isSitewide( $block->isSitewide() ); // Set the block id of the restrictions. + $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore(); $currentBlock->setRestrictions( - BlockRestriction::setBlockId( $currentBlock->getId(), $restrictions ) + $blockRestrictionStore->setBlockId( $currentBlock->getId(), $restrictions ) ); } @@ -1087,7 +1076,7 @@ class SpecialBlock extends FormSpecialPage { * * @todo strtotime() only accepts English strings. This means the expiry input * can only be specified in English. - * @see https://secure.php.net/manual/en/function.strtotime.php + * @see https://www.php.net/manual/en/function.strtotime.php * * @param string $expiry Whatever was typed into the form * @return string|bool Timestamp or 'infinity' or false on error.